import java.util.Scanner;

public class guess
{
    public static void main(String[] args)
    {
        //猜数字游戏
        Scanner sc = new Scanner(System.in);
        //生成一个随机数
        int number = (int)(Math.random()*100);//0-100 Math.random()为[0,1)
        System.out.println("请输入数字");
        while(true)
        {
            int num=sc.nextInt();
            if(num==number)
            {
                System.out.println("恭喜你猜对了");
                break;
            }
            else if(num>number)
            {
                System.out.println("猜大了");
                System.out.println("请重新输入数字");
            }
            else if(num<number)
            {
                System.out.println("猜小了");
                System.out.println("请重新输入数字");
            }
        }
    }
}
